package com.open.validator;



import com.open.validator.impl.NotBlankExtValidator;

import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.Documented;
import java.lang.annotation.Repeatable;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
 * 作用在类上，字段依赖于其他字段，其他字段有值或者为指定值时不能为kong
 */
@Documented
@Constraint(validatedBy = {NotBlankExtValidator.class})
@Target({ANNOTATION_TYPE, TYPE})
@Repeatable(NotBlankExt.List.class)
@Retention(RUNTIME)
public @interface NotBlankExt {

    String message() default "the field must not be empty!";

    /**
     * Allowable value
     */
    String[] value() default {};

    /**
     * @return Decorated fields
     */
    String field();

    /**
     * @return Dependent field
     */
    String depField();

    /**
     * @return Value of dependent field
     */
    String[] depValue() default {};

    Class<?>[] groups() default {};

    Class<? extends Payload>[] payload() default {};

    /**
     * Defines several {@code @NotBlankExt} constraints on the same element.
     */
    @Target({ANNOTATION_TYPE, TYPE})
    @Retention(RUNTIME)
    @Documented
    public @interface List {
        NotBlankExt[] value();
    }
}
